home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DRIVES.SWG / 0067_GIG Drive Size-Free.pas < prev    next >
Pascal/Delphi Source File  |  1994-02-03  |  1KB  |  45 lines

  1. {
  2. From: BO BENDTSEN
  3. Subj: Diskfree...
  4.  
  5.  MT> Has anyone noticed the problem with TP returning the wrong values from the
  6.  MT> DISKFREE function on large size HD's? We have a 2 gig drive at work
  7.  MT> (actual total is like 1900000000 bytes free), and pascal returns something
  8.  MT> like 576009491. All variables are longint.
  9.  
  10.  
  11. Many people does not think about it, but DOS is limited to report more than
  12. 1 gigabyte. Myself I have a 1.3 giga and a 1.0 giga, and made these routines
  13. for my programs for knowing if the size is more than 1 giga. Using the normal
  14. DiskSize and DiskFree could get you strange result, sometimes it could report
  15. maybe 100MB when it is really 1 giga.
  16.  
  17. If the size og free space is 1 you can assume that the drive is more than 1
  18. gigabyte.}
  19.  
  20. Function DriveSize(d:byte):Longint; { -1 not found, 1=>1 Giga }
  21. Var
  22.   R : Registers;
  23. Begin
  24.   With R Do
  25.   Begin
  26.     ah:=$36; dl:=d; Intr($21,R);
  27.     If AX=$FFFF Then DriveSize:=-1 { Drive not found }
  28.     Else If (DX=$FFFF) or (Longint(ax)*cx*dx=1073725440) Then DriveSize:=1
  29.     Else DriveSize:=Longint(ax)*cx*dx;
  30.   End;
  31. End;
  32.  
  33. Function DriveFree(d:byte):Longint; { -1 not found, 1=>1 Giga }
  34. Var
  35.   R : Registers;
  36. Begin
  37.   With R Do
  38.   Begin
  39.     ah:=$36; dl:=d; Intr($21,R);
  40.     If AX=$FFFF Then DriveFree:=-1 { Drive not found }
  41.     Else If (BX=$FFFF) or (Longint(ax)*bx*cx=1073725440) Then DriveFree:=1
  42.     Else DriveFree:=Longint(ax)*bx*cx;
  43.   End;
  44. End;
  45.